package com.fyt.reachgo.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import jakarta.persistence.*;
import lombok.Data;

/**
 * 智能生成的行程路线详情表
 * @TableName travel_route
 */
@TableName(value ="travel_route")
@Data
@Entity
@Table(name = "travel_route")
public class TravelRoute implements Serializable {
    /**
     * 路线唯一标识
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY) // 确保使用自增策略
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 关联规划请求ID
     */
    @Column(name = "request_id", nullable = false)
    private String requestId;

    /**
     * JSON格式路线数据（包含每日行程、交通、景点等详细信息）
     */
    @Column(columnDefinition = "JSON")
    @TableField(typeHandler = JacksonTypeHandler.class) // 使用 JacksonTypeHandler 处理 JSON
    private Object routeData;

    /**
     * 路线生成时间
     */
    @Column(name = "generated_time")
    private LocalDateTime generatedTime;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        TravelRoute other = (TravelRoute) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getRequestId() == null ? other.getRequestId() == null : this.getRequestId().equals(other.getRequestId()))
            && (this.getRouteData() == null ? other.getRouteData() == null : this.getRouteData().equals(other.getRouteData()))
            && (this.getGeneratedTime() == null ? other.getGeneratedTime() == null : this.getGeneratedTime().equals(other.getGeneratedTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getRequestId() == null) ? 0 : getRequestId().hashCode());
        result = prime * result + ((getRouteData() == null) ? 0 : getRouteData().hashCode());
        result = prime * result + ((getGeneratedTime() == null) ? 0 : getGeneratedTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", requestId=").append(requestId);
        sb.append(", routeData=").append(routeData);
        sb.append(", generatedTime=").append(generatedTime);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}